/**
 * 默认的标签样式
 */
const DEFAULT_TAG_CSS: string = "color: black;" +
    "font-family: sans-serif;" +
    "font-weight: normal;" +
    "border-radius: 5px;" +
    "border-style: solid;";

/**
 * 默认的日志消息样式
 */
const DEFAULT_MSG_CSS: string = "color: white;" +
    "font-family: sans-serif;" +
    "font-weight: normal;";

/**
 * 为标签指定背景与边线的颜色
 * @param color
 */
export function coloredTagCss(color: string): string {
    return `${DEFAULT_TAG_CSS} background-color: ${color};
    border-color: ${color};`;
}

/**
 * 日志样式配置类
 */
export class LogStyleConfig {

    constructor(tagText: string, tagCss: string, msgCss: string) {
        this._tagText = tagText;
        this._tagCss = tagCss;
        this._msgCss = msgCss;
    }

    /**
     * 标签文字
     * @private
     */
    private _tagText: string;

    get tagText(): string {
        return this._tagText;
    }

    set tagText(value: string) {
        this._tagText = value;
    }

    /**
     * 标签的样式
     * @private
     */
    private _tagCss: string;

    get tagCss(): string {
        return this._tagCss;
    }

    set tagCss(value: string) {
        this._tagCss = value;
    }

    /**
     * 日志消息的样式
     * @private
     */
    private _msgCss: string;

    get msgCss(): string {
        return this._msgCss;
    }

    set msgCss(value: string) {
        this._msgCss = value;
    }
}

/**
 * 消息日志样式表
 */
export const LogStyles: { [levelName: string]: LogStyleConfig } = {
    trace: new LogStyleConfig("TRACE", coloredTagCss("white"), DEFAULT_MSG_CSS),
    debug: new LogStyleConfig("DEBUG", coloredTagCss("lightskyblue"), DEFAULT_MSG_CSS),
    info: new LogStyleConfig("INFO", coloredTagCss("lightgreen"), DEFAULT_MSG_CSS),
    warn: new LogStyleConfig("WARN", coloredTagCss("orange"), DEFAULT_MSG_CSS),
    error: new LogStyleConfig("ERROR", coloredTagCss("lightcoral"), DEFAULT_MSG_CSS)
};
